package conservare.dao;

import java.util.List;

import javax.persistence.EntityTransaction;

import conservare.modelo.localservico.LocalPrestacaoServico;

public class LocalPrestacaoServicoDAO extends Dao{

	private static final long serialVersionUID = 1500966038271807695L;

	public LocalPrestacaoServico salvar(LocalPrestacaoServico localPrestacaoServico) {
		
		EntityTransaction transaction = getEm().getTransaction();
		transaction.begin();
		
		if(localPrestacaoServico.getId() == null)
			getEm().persist(localPrestacaoServico);
		else
			getEm().merge(localPrestacaoServico);
		
		transaction.commit();
		
		return localPrestacaoServico;
	}
	
	public LocalPrestacaoServico getById(Integer id) {
		return getPojo(LocalPrestacaoServico.class, id);
	}

	public List<LocalPrestacaoServico> getTodos() {
		return getList(LocalPrestacaoServico.class, "select a from LocalPrestacaoServico a order by a.descricao");
	}
}
